<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<c:if test="${empty pass}">
    <c:redirect url="admin_home"></c:redirect>
</c:if>

<script type="text/javascript" src = "rsrc/js/jquery.validationEngine-en.js"></script>
<script type="text/javascript" src = "rsrc/js/jquery.validationEngine.js"></script>

<script>
    $(document).ready(function(){
        
        $('#delUser').attr('disabled', 'disabled');
        $('input[name="user"]').click(function(){
            $('#delUser').removeAttr('disabled', 'disabled');
        });
        
        $('#addUser').click(function(){
            var ch = $('#ut').val();
            $('#addForm').load('admin_form',{ut:ch},function(){
                 $('#cancelUserForm').click(function(){
                     $('#addForm').html("");
                 });
            });
        });
    });
</script>
<div class="separator"></div>
<div id="table_of_users">
   
   <form id="deleteUser" action="admin_action" method="post">
        <table class="enrollment_sched">
            <thead>
                <tr>
                    <th></th>
                    <th>Username</th>
                    <th>First Name</th>
                    <th>Middle Name</th>
                    <th>Last Name</th>
                    <th>Email</th>
                </tr>
            </thead>
            <tbody>                                   
                <c:forEach var="userList" items="${userList}" >
                    <tr>
                        <td>
                            <input type="radio" name="user" id="user" value="${userList.userIDCrypt}">
                        </td>
                        <td>${userList.username}</td> 
                        <td>${userList.firstName}</td>
                        <td>${userList.midName}</td>
                        <td>${userList.lastName}</td>
                        <td>${userList.email}</td> 
                    </tr>
                </c:forEach>
            </tbody>
        </table>
        <br/>
        
        <input type="hidden" name="form" id="form" value="$#!@e"/>
        <c:if test="${!customer}">
            <input type="button" class="gb" id ="addUser" name="addUser" value="Add User"/>
        </c:if>
        <input type="submit" class="gb" id ="delUser" name="delUser" value="Delete User"/>
    </form>
    <input type="hidden" name="ut" id="ut" value="${userType}">
   <c:if test="${empty userList}">
       <span class="label">Sorry, no user is registered  for this User Type.</span>
   </c:if>
   <div id="addForm"></div>
  
</div>